
public class GenericsTest1<T> {//申明泛型

    public void test(T t) {//使用泛型
//        System.out.println(t.getName());
        System.out.println(t);
    }

    static class Dog {
        private String name;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

    }

    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.setName("小黑");

        new GenericsTest1<Dog>().test(new Dog());
    }
}
